package com.ysfxt.exception;


import com.ysfxt.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 盐酸氟西汀
 * @create 2024/3/29 19:27
 * @email 480738950@qq.com
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail(null );
    }
    
    //自定义异常处理
    /**
     * 自定义异常处理方法
     * @param e
     * @return
     */
    @ExceptionHandler(YsfxtException.class)
    @ResponseBody
    public Result error(YsfxtException e){
        return Result.build(null,e.getCode(), e.getMessage());
    }
}